package com.ss.android.lockscreen.activity.lock;

import android.content.Context;
import android.support.design.a;
import com.ss.android.lockscreen.bb;
import com.ss.android.lockscreen.e.e$c;
import org.json.JSONException;
import org.json.JSONObject;

import inline.TextDemo;

final class o implements Runnable {
    public final n a;
    private final Context b;

    o(n arg1, Context arg2) {
        this.a = arg1;
        this.b = arg2;

    }

    private void a() {
        this.a.b.post(new q(this));
    }

    public final void run() {
        if(bb.a().d == null) {
            this.a();
            return;
        }

        Context v0 = this.b;
        StringBuilder v1 = new StringBuilder("http://open.snssdk.com/auth/access/device/?");
        android.support.design.a.a(v1, v0);
        String v0_1 = e$c.a(v1.toString());
        if(TextDemo.c(v0_1)) {
            this.a();
            return;
        }

        try {
            JSONObject v1_1 = new JSONObject(v0_1);
            if(!android.support.design.a.b(v1_1)) {
                com.ss.android.lockscreen.utils.a.a("LockScreenLoader", "get article info error: " + v1_1);
                this.a();
                return;
            }

            JSONObject v0_3 = v1_1.getJSONObject("data");
            com.ss.android.lockscreen.http.data.b v1_2 = new com.ss.android.lockscreen.http.data.b();
            v1_2.a = v0_3.optString("access_token");
            v1_2.b = System.currentTimeMillis() + v0_3.optLong("expires_in") * 1000;
            this.a.b.post(new p(this, v1_2));
        }
        catch(JSONException v0_2) {
            this.a();
        }
    }
}

